# -*- coding:utf-8 -*-


##获取系统默认字符编码
import sys
#sys.setdefaultencoding("utf-8")
print sys.getdefaultencoding()



str1=unicode("中文","utf-8")
print str1
print str1.encode("utf-8")


str2="中文"
#将字符串转化为unicode编码
ustr2=str2.decode("utf-8")

#判断字符串是否为unicode编码
print isinstance(str2, unicode) #False
print isinstance(ustr2, unicode) #True

#将unicode字符串转化为目标编码
print ustr2.encode("utf-8")
print repr(ustr2.encode("gbk"))

#字符串前带u,默认采用unicode编码存储
ustr3=u"中文"
print ustr3
print ustr3.encode("utf-8")



#用中文来做数组成员进行枚举
words=["一六","二","三","四","五","二"]

for word in words:
    if isinstance(word,unicode):
        print word,repr(word)
    else:
        print word,repr(word)
        word.decode("utf-8")
        #print word.encode("utf-8")
        #word.encode("ascii")
        if isinstance(word,unicode):
            print word,repr(word)
        
if words[1]==words[5]:
    print words[5]











